//按钮事件新增或编辑
var C334T0_type = "";
//其他页面传到本页面参数
var C334T0_param = {};
//暂时没用
var C334T0_validate = "";
//当前触发按钮
var C334T0_btn = "";

/*定义下拉框集合定义*/
/*declare select options begin*/
/*declare select options end*/

//输入框默认值
function C334T0_input_default(){
	//所有输入框设置默认值
	/*Input Default Begin*/
	/*Input Default End*/
}

//主从表传递参数
function C334T0_param_set(){
    //输入框默认值
	C334T0_input_default();
	/*Main Subsuv Table Param Begin*/
    if(C334T0_param.hasOwnProperty("MAIN_ID"))
        $("#C334T0_MAIN_ID").val(s_decode(C334T0_param["MAIN_ID"]));
    if(C334T0_param.hasOwnProperty("NICK_NAME"))
        $("#C334T0_NICK_NAME").val(s_decode(C334T0_param["NICK_NAME"]));
	
	/*Main Subsuv Table Param end*/
}

//业务逻辑数据开始
function C334T0_biz_start(inputdata) {
	C334T0_param = inputdata;

	C334T0_init_reset_pwd();	
    /*biz end*/
}

/*biz step begin*/
/*biz step end*/

/*查找框函数*/
/*find qry fun begin*/
/*find qry fun end*/

/*页面结束*/
function C334T0_page_end(){
}

//页面初始化方法
function C334T0_init_reset_pwd() {
	//type = getUrlParam("type");
	C334T0_param_set();
	
	//表单验证
	C334T0_checkFormInput();
	/*时间格式初始化*/
	/*form datetime init begin*/
	
    /*form datetime init end*/
	
	C334T0_page_end();
}

//提交表单数据
function C334T0_SubmitForm(){
	$("#C334T0_MSG").html("");
	var pwdRegex = new RegExp('(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[^a-zA-Z0-9]).{8,30}');
//	var pwdRegex = new RegExp('^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&*]+$)(?![a-zA-z\d]+$)(?![a-zA-z!@#$%^&*]+$)(?![\d!@#$%^&*]+$)[a-zA-Z\d!@#$%^&*]+$.{8,30}')
//	var pwdRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
	if (!pwdRegex.test($("#C334T0_PWD1").val())) {
		$("#C334T0_MSG").html("<font color='red'>提交失败,您的密码复杂度太低（密码中必须包含大小写字母、数字、特殊字符）!</fond>");
		//swal("提交失败!", "失败原因:您的密码复杂度太低（密码中必须包含大小写字母、数字、特殊字符）,最小8位", "warning");
		return false;
	}
	else if ($("#C334T0_PWD1").val() != $("#C334T0_PWD2").val()) {
		$("#C334T0_MSG").html("<font color='red'>提交失败,密码输入不一致</fond>");
		//swal("提交失败!", "失败原因:密码重复不一致", "warning");
		return false;
	}
	$("#C334T0_MSG").html("<font color='green'>密码校验通过</fond>");
	var inputdata = {
			"param_name": "N01_TTJ334",
			"session_id": session_id,
			"login_id": login_id
            /*insert param begin*/
            ,"param_value1": s_encode($("#C334T0_MAIN_ID").val())
            ,"param_value2": s_encode($("#C334T0_NICK_NAME").val())
            ,"param_value3": s_encode($("#C334T0_PWD1").val())
			
            /*insert param end*/
		};
	get_ajax_baseurl(inputdata, "C334T0_get_N01_TTJ334");
}

//保存成功
function C334T0_get_N01_TTJ334(input){
	layer.close(ly_index);
	if (Call_OpeResult(input.N01_TTJ334) == true)
	{
		swal("密码重置成功!", "", "success");
		C334T0_clear_validate();
		layer.close(C334T0_param["ly_index"]);
	}
}

//vue回调
function C334T0_call_vue(objResult){
	if(index_subhtml == "XXXXXX")
	{
		
	}
	/*查询条件弹窗子页面*/
    /*get find subvue bgein*/
	/*get find subvue end*/
}

//for表单提交
$("#C334T0_save_Edit").click(function () {
	$("form[name='C334T0_DataModal']").submit();
})

//取消编辑
$("#C334T0_cancel_Edit").click(function () {
	layer.close(C334T0_param["ly_index"]);
	C334T0_clear_validate();
	$("[id^='C334T0_div']").hide();
})

//清除验证缓存
function C334T0_clear_validate(){
	$("#C334T0_DataModal").find(".has-error").each(function(){
		$(this).removeClass('has-error');
	});
	$("#C334T0_DataModal").find(".has-success").each(function(){
	 	$(this).removeClass('has-success');
	});
	$("#C334T0_DataModal").find(".glyphicon").each(function(){
	 	$(this).remove();
	});
}

//输入框重置
function C334T0_clear_edit_info(){
	var inputs = $("#C334T0_DataModal").find('input');
	var selects = $("#C334T0_DataModal").find("select");
	var textareas = $("#C334T0_DataModal").find('textarea');
	var divs = $("div[id^='C334T0'][id$='FILE_div']");  
	$.each(inputs, function (i, obj) {
		$(obj).val("");
	});
	$.each(selects, function (i, obj) {
		$(obj).val("");
	});
	$.each(textareas, function (i, obj) {
		$(obj).val("");
	});
	$.each(divs, function (i, obj) {
		$(obj).html("");
	});
	/*清除输入框验证信息*/
	/*input validate clear begin*/
	
	/*input validate clear end*/
	C334T0_init_t_user_info();
}

//页面输入框赋值
function C334T0_get_edit_info(){
	//通用子页面输入框赋值
	
	//树型结构父类赋值
	/*tree pid set value begin*/
	/*tree pid set value end*/
	
	/*文件附件格式*/
	/*input param fileinfo begin*/
	
	/*input param fileinfo end*/
}

//form验证
function C334T0_checkFormInput() {
    C334T0_validate = $("#C334T0_DataModal").validate({
        errorElement: 'span',
        errorClass: 'help-block',
        rules: {
        	/*input check rules begin*/
            C334T0_MAIN_ID: {}
    		,C334T0_NICK_NAME: {}
            ,C334T0_PWD1: {required : true,maxlength:30}
            ,C334T0_PWD2: {required : true,maxlength:30}
			
            /*input check rules end*/
        },
        messages: {
        	/*input check messages begin*/
            C334T0_MAIN_ID: {}
			,C334T0_NICK_NAME: {}
            ,C334T0_PWD1: {maxlength:"长度不能超过30"}
            ,C334T0_PWD1: {maxlength:"长度不能超过30"}
			
            /*input check messages end*/
        },
        errorPlacement: function (error, element) {
            element.next().remove();
            element.after('<span class="glyphicon glyphicon-remove form-control-feedback" aria-hidden="true"></span>');
            element.closest('.form-group').append(error);
        },
        highlight: function (element) {
            $(element).closest('.form-group').addClass('has-error has-feedback');
        },
        success: function (label) {
            var el = label.closest('.form-group').find("input");
            el.next().remove();
            el.after('<span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>');
            label.closest('.form-group').removeClass('has-error').addClass("has-feedback has-success");
            label.remove();
        },
        submitHandler: function (form) {
        	C334T0_SubmitForm();
        	return false;
        }
    })
}